<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html lang="en">
<head>
<title>任务管理</title>
<!-- 360浏览器以极速模式显示 -->
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE10" />
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" type="text/css" href="sidebar/css/default.css" />
<link rel="stylesheet" type="text/css" href="sidebar/css/component.css" />
<script src="sidebar/js/modernizr.custom.js"></script>
<script src="sidebar/js/classie.js"></script>
<link rel="stylesheet" href="css/bootstrap.min.css" />
<link rel="stylesheet" href="css/matrix-style.css" />
<link rel="stylesheet" href="css/matrix-media.css" />
<link rel="stylesheet" href="jquery-easyui/themes/default/easyui.css" />
<link rel="stylesheet" href="jquery-easyui/themes/icon.css" />
<script type="text/javascript" src="jquery-easyui/jquery.min.js"></script>
<script type="text/javascript" src="jquery-easyui/jquery.easyui.min.js"></script>
<script charset="utf-8" src="editor/kindeditor-all.js"></script>
<script charset="utf-8" src="editor/lang/zh-CN.js"></script>
<link rel="stylesheet" href="editor/themes/default/default.css"></link>
<script type="text/javascript" src="editor/plugins/code/prettify.js"></script>
<script src="js/bootstrap.min.js"></script>
<style>
.content-header {
	/*   margin-top:-38px;
 */
	font-size: 16px;
	background-color: #fff;
}

.content-header table {
	font-weight: bolder;
	margin-left: 30px;
}

.content-header .header-number {
	margin-left: 10px;
}

.width30 {
	width: 50%;
}

.width70 {
	width: 50%;
}

.table th, .table td {
	text-align: center;
}
/*easyui*/
#fm {
	margin: 0;
	padding: 10px 30px;
}

.ftitle {
	font-size: 14px;
	font-weight: bold;
	padding: 5px 0;
	margin-bottom: 10px;
	border-bottom: 1px solid #ccc;
}

.fitem {
	margin-bottom: 5px;
}

.fitem label {
	display: inline-block;
	width: 80px;
}

.fitem input {
	width: 160px;
} 
/*  #ul1 li{
 list-style:none;
 float:left;
 height:60px;
 line-height:60px;
 display:inline-block;
 width:50%;
} */
#right-handle li{
 float:left;
 margin:20px;
 opacity:1;
 font-size:12px;
 color:white;
font-weight:1;

}
#right-handle{
 position:absolute;
 top:12px;
 color:white;
 right:100px;
}

#right-handle li:hover{
 cursor:pointer;  
}
#right-task-tab tr:hover{
 cursor:pointer;  
}

/*modal*/
#modal-h5{
    color: #afdefa;
	font-size: 1.9em;
	padding: 20px;
	margin: 0;
	font-weight: 300;
	background: #0d77b6;
}
.panel-window{
 z-index:100000;
}
</style>
<script type="text/javascript">
$(document).ready(function(){
	$.ajax({
		url:"<%=request.getContextPath()%>/task?method=taskcount",
		dataType:'json',
		type:'post',
		data:{},
		beforeSend:function(){
			
		},
		success:function(result){
			if(result.success){
				$("#count").text(result.count);
			}
		}
	})
	$('#dg').datagrid({
	        width:'95%',
	        title:'任务管理',
		    pagination:false,
		    rownumbers:true,
		    fitColumns:true,
		    singleSelect:true,
		    idField:'id',
		    url:'<%=request.getContextPath()%>/task?method=unfinishlist',
		    columns:[[
		        {field:'ck',checkbox:true},
		        {field:'id',title:'编号'},
		        {field:'name',title:'任务名称',width:"60%",
		        	styler:function(value,row,index){
					    if(row.status==1){
							return 'text-decoration:line-through;';
					    }else{
					    	return;
					    }
		          }
			     },
		        {field:'content',title:'任务内容',hidden:true},
		        {field:'assistid',title:'创建人',hidden:true},
		        {field:'parentid',title:'父任务',hidden:true},
		        {field:'due',title:'任务到期时间',width:"30%"},
		        {field:'responsibility',title:'任务负责人',hidden:true},
		        {field:'attachmenturl',title:'任务负责人',hidden:true},
		        {field:'status',title:'任务状态',hidden:true}
		    ]],
		   onClickRow: function (index, row,event) {//点击事件
			var menuRight = document.getElementById( 'cbp-spmenu-s2' );
			classie.add( menuRight, 'cbp-spmenu-open' );
			var e=arguments.callee.caller.arguments[0] || window.event; 
			e.stopPropagation();
			 /*right页面的赋值*/
			 $.ajax({
				 url:'<%=request.getContextPath()%>/task?method=rightlist',
				 type:'post',
				 dataType:'json',
				 data:{id:row.id,parentid:row.parentid},
				 beforeSend:function(){
					 
				 },
				 success:function(result){
					 if(result.success){
						//子任务
						 var str='';
						 $.each(result.list,function(i,item){
							 str+='<tr data-toggle="modal" href="#myModal" onclick="addAttr('+item.id+'\,'+item.parentid+')"><td>'+item.name+'</td><td>'+item.due+'</td></tr>';
						 })
						 $("#right-task-tab").html(str);
						 
						 //上级任务
						 if(result.taskparent==null){
							 $("#parent-content").html("");
						 }else{
							 var str2='<a href="#" onclick="reloadright('+result.taskparent.id+','+result.taskparent.parentid+')">'+result.taskparent.name+'</a>';
							 $("#parent-content").html(str2);
						 }
						 //参与人
						 if(result.joins!=null){
							 var str3='';
							 $.each(result.joins,function(i,item){
							   str3+='<span style="padding:20px;font-size:16px;" onmouseover="showspanjoin(this)" onmouseout="hidespanjoin(this)">'+item.id+
							   '<span class="easyui-linkbutton"  style="position:relative;top:-5px;font-size:20px;margin-left:10px;display:none" onclick="deletejoin(this)">x</span></span>';
							   
							 });
							 $("#join-right").html(str3);

						 }else{
							 $("#join-right").html("");
						 }
						 
						//关联的会员
						if(result.listuser!=null){
							var str="";
							$.each(result.listuser,function(i,item){
								str+='<li onmouseover="showspanuser(this)" onmouseout="hidespanuser(this)"><a style="display:inline-block;"  href="#" onclick="userInfo(\''+item.uid+'\')">'+item.uid+'</a><span style="position:relative;top:-5px;font-size:16px;margin-left:10px;display:none" onclick="deleteuser(this\,\''+item.uid+'\')">x</span></li>';
							})
							$("#right-users").html(str);
							
						}else{
							$('#right-users').html('');
						}
						
						//附件
						if(result.listurl!=null){
							var str='';
							$.each(result.listurl,function(i,item){
								str+='<div onmouseover="showspanattachment(this)" onmouseout="hidespanattachment(this)"><a style="display:inline;" href="'+item[1]+'">'+item[2]+'</a>'+
								'<span class="easyui-linkbutton"  style="position:relative;top:-5px;font-size:16px;margin-left:10px;display:none;" onclick="deleteattachment(this,'+item[0]+')">x</span></div>';
							})
							$("#attachment").html(str);
						}else{
							$("#attachment").html('');
						}
						
						//关联的活动
						if(result.listtravel!=null){
							var str="";
							$.each(result.listtravel,function(i,item){
								str+='<li onmouseover="showspantravel(this)" onmouseout="hidespantravel(this)"><a style="display:inline-block;" href="#" onclick="travelInfo('+item.id+')">'+item.title+
				       			 '</a><span   style="position:relative;top:-5px;font-size:16px;margin-left:10px;" onclick="deletetravel(this\,'+item.id+')">x</span></li>';
							})
							$("#right-travel").html(str);
						}else{
							$("#right-travel").html("");
						}
					 }
				 }
			 })
			 //设置right页面的内容
			 $("#right-name").val(row.name);//设置name
			 $("#right-content").val(row.content);//设置内容
			 $("#div1").css("display","none");
  			 $("#responseibility").text(row.responsibility);
  			 $("#right-due").text(row.due);
  			 $("#div2").css('display','none');
  			 $("#right-join").append();
  			 $("#div3").css("display",'none');
  			 $("#div4").css('display','none');
  			 $('#mycom4').combogrid('grid').datagrid('load');//datagrid任务更新后，要求right comgrid的数据要同步
  			 $("#div7").css('display','none');
  			 if(row.status==0){
  				 $("#right-handle li:first").text("标记完成");
  			 }else{
  				 $("#right-handle li:first").text("标记未完成");
  				 
  			 }
	     }
	    	 
		});
	
	//header menu
	var ddlMenu1 = $('#li1').menubutton({ menu: '#cusmenu1' }); 
	var ddlMenu2 = $('#li2').menubutton({ menu: '#cusmenu2' }); 
	
	//menubutton 依赖于 menu、linkbutton 这两个插件，所以我们可以这样搞定她
	$(ddlMenu1.menubutton('options').menu).menu({
            onClick: function (item) {
            	if(item.id=='id1'){
            		
            	}else if(item.id=='id2'){
                    window.open("<%=request.getContextPath()%>/task?method=assisttasks","_blank")

            	}else if(item.id=='id3'){
                    window.open("<%=request.getContextPath()%>/","_self")

            	}
            }
	})
	$(ddlMenu2.menubutton('options').menu).menu({
	            onClick: function (item) {
	            	 if(item.id=='id4'){
	            	}
	            }
	})
	
	
});

window.onload=function(){
 	 $("#responseibility-btn").click(function(event){
		 showCombox1();	
		 event.stopPropagation();
		}) 

	$("#responseibility-btn2").click(function(event){
		showdatebox();
		event.stopPropagation();
	})

	$("#responseibility-btn3").click(function(event){
		showjoins();
		event.stopPropagation();
	})
    	
	$("#responseibility-btn6").click(function(event){
		showusers();
		event.stopPropagation();

	})
	$("#responsibility-btn7").click(function(event){
		showCombox7();
		event.stopPropagation();

	})
	$(".cbp-spmenu-push").click(function(){
		hideCombox1();
		hideusers();
		hidedatebox();
		hdiejoins();
		hideCombox7();
	})
	/*-----------------task编辑绑定事件------------------*/
	$("#right-name").change(function(){
		var row=$("#dg").datagrid('getSelected');
		$.ajax({
			url:'<%=request.getContextPath()%>/task?method=updatename',
			dataType:'json',
			type:'post',
			data:{name:$(this).val(),id:row.id},
			beforeSend:function(){
				
			},
			success:function(data){
				if(data.success){
					$.messager.show({
						title:'提示',
						msg:'任务创建成功'
					})
					$("#dg").datagrid("reload");
				}
			}
		})
	})
	
		$("#right-content").change(function(){
		var row=$("#dg").datagrid('getSelected');
		$.ajax({
			url:'<%=request.getContextPath()%>/task?method=updatecontent',
			dataType:'json',
			type:'post',
			data:{content:$(this).val(),id:row.id},
			beforeSend:function(){
				
			},
			success:function(data){
				if(data.success){
					$.messager.show({
						title:'提示',
						msg:'修改成功'
					})
					$("#dg").datagrid("reload");
				}
			}
		})
	})
<%-- 	$("#right-subname").change(function(){
		
		var row=$("#dg").datagrid('getSelected');
			$.ajax({
				url:'<%=request.getContextPath()%>/task?method=addsub',
				dataType:'json',
				type:'post',
				data:{name:$("#right-subname").val(),parentid:row.id},
				beforeSend:function(){
					if($("#right-subname").val()==""||$("#right-subname").val()==null){
						return false;
					}
					return true;
				},
				success:function(data){
					if(data.success){
						$.messager.show({
							title:'提示',
							msg:'创建成功'
						})
						var str='<tr><td>'+$("#right-subname").val()+'</td><td>'+new Date().toLocaleDateString()+'</td></tr>';
						$("#right-task-tab").prepend(str);
						$("#dg").datagrid('reload');
					}
				}
			})
	}) --%>
	/*---------------------自定义验证----------------------------*/
/*  	$.extend($.fn.validatebox.defaults.rules, {
		indeditor:{
			validator:function(value,param){
				alert(value);
				if(value.length>param[0]){
					alert('true')
					return true;
				}
			},
			message:'not null'
		}
	}) */


	$("#myModal").unbind('shown.bs.modal').bind('shown.bs.modal',function(e){
		
			console.log('shown.bs.modal');
			var btn=$('#myModal');
			var id=btn.attr('data-id');
			var parentid=btn.attr('data-parentid');
			reloadright_modal(id,parentid);
	})
	
}
function addAttr(id,parentid){
	console.log('addattr');
	$("#myModal").attr('data-id',id);
	$('#myModal').attr('data-parentid',parentid);
}

KindEditor.ready(function(K) {
	var editor = K.editor({
		resizeType: 1,
		fullscreenMode: 0, //是否全屏显示
		designMode: 1,
		uploadJson:'editor/jsp/upload_json.jsp',
	    fileManagerJson : 'editor/jsp/file_manager_json.jsp',
		allowPreviewEmoticons: false,
		allowImageUpload: true,
		allowFileManager: true
	});
	K('#insertfile').click(function() {
		editor.loadPlugin('insertfile', function() {
			editor.plugin.fileDialog({
				clickFn : function(url, title) {
					var row=$("#dg").datagrid("getSelected");
					/* var str='<div onmouseover="showspanattachment(this)" onmouseout="hidespanattachment(this)"><a style="display:inline;" href="'+url+'">'+title+'</a>'+
					'<span class="easyui-linkbutton"  style="position:relative;top:-5px;font-size:16px;margin-left:10px;display:none;" onclick="deleteattachment()">x</span></div>';
					$('#attachment').append(str); */
					$.ajax({
						url:'<%=request.getContextPath()%>/task?method=addattachment',
						dataType:'json',
						type:'post',
						data:{taskid:row.id,url:url,title:title},
						beforeSend:function(){
							
						},
						success:function(result){
							reloadright(row.id,row.parentid);
						}
					});
					editor.hideDialog();
				}
			});
		});
	});
	
	K('#insertfile_modal').click(function() {
		editor.loadPlugin('insertfile', function() {
			editor.plugin.fileDialog({
				clickFn : function(url, title) {
					var row=$("#dg").datagrid("getSelected");
					/* var str='<div onmouseover="showspanattachment(this)" onmouseout="hidespanattachment(this)"><a style="display:inline;" href="'+url+'">'+title+'</a>'+
					'<span class="easyui-linkbutton"  style="position:relative;top:-5px;font-size:16px;margin-left:10px;display:none;" onclick="deleteattachment()">x</span></div>';
					$('#attachment').append(str); */
					$.ajax({
						url:'<%=request.getContextPath()%>/task?method=addattachment',
						dataType:'json',
						type:'post',
						data:{taskid:row.id,url:url,title:title},
						beforeSend:function(){
							
						},
						success:function(result){
							reloadright(row.id,row.parentid);
						}
					});
					editor.hideDialog();
				}
			});
		});
	});
	
}); 
function cancelright(){
    var menuRight = document.getElementById( 'cbp-spmenu-s2' );
	classie.remove( menuRight, 'cbp-spmenu-open' );
}


/*---------点击上级任务时，重载----------*/
function reloadright(id,parentid){
	 $.ajax({
		 url:'<%=request.getContextPath()%>/task?method=rightlist',
		 type:'post',
		 dataType:'json',
		 data:{id:id,parentid:parentid},
		 beforeSend:function(){
			 
		 },
		 success:function(result){
			 if(result.success){
				 //子任务
				 var str='';
				 $.each(result.list,function(i,item){
					 str+='<tr data-toggle="modal" href="#myModal" ><td>'+item.name+'</td><td>'+item.due+'</td></tr>';
				 })
				 $("#right-task-tab").html(str);
						 
				 //上级任务
				 if(result.taskparent==null){
					 $("#parent-content").text("");

				 }else{
					 var str2='<a href="#" id='+result.task.id+' onclick="reloadright()">'+result.task.name+'</a>';
					 $("#parent-content").html(str2);
				 }
				 //参与者
				 if(result.joins!=null){
					 var str3='';
					 $.each(result.joins,function(i,item){
					   str3+='<span style="padding:20px;font-size:16px;" onmouseover="showspanjoin(this)" onmouseout="hidespanjoin(this)">'+item.id+
					   '<span class="easyui-linkbutton"  style="position:relative;top:-5px;font-size:20px;margin-left:10px;display:none" onclick="deletejoin(this)">x</span></span>';
					   
					 });
					 $("#join-right").html(str3);

				 }else{
					 $("#join-right").html("");
				 }
				 
				//关联的会员
					if(result.listuser!=null){
						var str="";
						$.each(result.listuser,function(i,item){
							str+='<li onmouseover="showspanuser(this)" onmouseout="hidespanuser(this)"><a style="display:inline-block;"  href="#" onclick="userInfo(\''+item.uid+'\')">'+item.uid+'</a><span style="position:relative;top:-5px;font-size:16px;margin-left:10px;display:none" onclick="deleteuser(this\,\''+item.uid+'\')">x</span></li>';
						})
						$("#right-users").html(str);
						
					}else{
						$('#right-users').html('');
					}
				//附件
					if(result.listurl!=null){
						var str='';
						$.each(result.listurl,function(i,item){
							str+='<div onmouseover="showspanattachment(this)" onmouseout="hidespanattachment(this)"><a style="display:inline;" href="'+item[1]+'">'+item[2]+'</a>'+
							'<span class="easyui-linkbutton"  style="position:relative;top:-5px;font-size:16px;margin-left:10px;display:none;" onclick="deleteattachment(this,'+item[0]+')">x</span></div>';
						})
						$("#attachment").html(str);
					}else{
						$("#attachment").html('');
					}
				
					//关联的活动
					if(result.listtravel!=null){
						var str="";
						$.each(result.listtravel,function(i,item){
							str+='<li onmouseover="showspantravel(this)" onmouseout="hidespantravel(this)"><a style="display:inline-block;" href="#" onclick="travelInfo('+item.id+')">'+item.title+
			       			 '</a><span   style="position:relative;top:-5px;font-size:16px;margin-left:10px;" onclick="deletetravel(this\,'+item.id+')">x</span></li>';
						})
						$("#right-travel").html(str);
					}else{
						$("#right-travel").html("");

					}
				 
				 $("#right-name").val(result.taskself.name);//设置name
				 $("#right-content").val(result.taskself.content);//设置内容
				 $("#div1").css("display","none");
				 $("#responseibility").text(result.taskself.responsibility);
				 $("#right-due").text(result.taskself.due);
				 $("#div2").css('display','none');
				 $("#div3").css("display",'none');
				 $("#div4").css('display','none');
				 //点击上级元素时，同步row
				 var rows=$("#dg").datagrid("getRows");
				 for(var i=0;i<rows.length;i++){
					 if(rows[i].id==result.taskself.id){
						 $("#dg").datagrid('selectRow',i);
						 break;
					 }
				 }
				 var row=$("#dg").datagrid("getSelected");
				 if(row.status==0){
	  				 $("#right-handle li:first").text("标记完成");
	  			 }else{
	  				 $("#right-handle li:first").text("标记未完成");
	  			 }
			 }
		 }
	 })
}
/*------------------------------模态框 ----------------------------------------*/
function reloadright_modal(id,parentid){
	 $.ajax({
		 url:'<%=request.getContextPath()%>/task?method=rightlist',
		 type:'post',
		 dataType:'json',
		 data:{id:id,parentid:parentid},
		 beforeSend:function(){
			 
		 },
		 success:function(result){
			 if(result.success){
				 //子任务
				 var str='';
				 $.each(result.list,function(i,item){
					 str+='<tr data-toggle="modal" href="#myModal" onclick="addAttr('+item.id+'\,'+item.parentid+')"><td>'+item.name+'</td><td>'+item.due+'</td></tr>';
				 })
				 $("#right-task-tab_modal").html(str);
						 
				 //上级任务
				 if(result.taskparent==null){
					 $("#parent-content_modal").text("");
				 }else{
					 var str2='<a href="#" id='+result.taskparent.id+' onclick="reloadright()">'+result.taskparent.name+'</a>';
					 $("#parent-content_modal").html(str2);
				 }
				 //参与者
				 if(result.joins!=null){
					 var str3='';
					 $.each(result.joins,function(i,item){
					   str3+='<span style="padding:20px;font-size:16px;" onmouseover="showspanjoin(this)" onmouseout="hidespanjoin(this)">'+item.id+
					   '<span class="easyui-linkbutton"  style="position:relative;top:-5px;font-size:20px;margin-left:10px;display:none" onclick="deletejoin(this)">x</span></span>';
					   
					 });
					 $("#join-right_modal").html(str3);

				 }else{
					 $("#join-right_modal").html("");
				 }
				 
				//关联的会员
					if(result.listuser!=null){
						var str="";
						$.each(result.listuser,function(i,item){
							str+='<li onmouseover="showspanuser(this)" onmouseout="hidespanuser(this)"><a style="display:inline-block;"  href="#" onclick="userInfo(\''+item.uid+'\')">'+item.uid+'</a><span style="position:relative;top:-5px;font-size:16px;margin-left:10px;display:none" onclick="deleteuser(this\,\''+item.uid+'\')">x</span></li>';
						})
						$("#right-users_modal").html(str);
						
					}else{
						$('#right-users_modal').html('');
					}
				//附件
					if(result.listurl!=null){
						var str='';
						$.each(result.listurl,function(i,item){
							str+='<div onmouseover="showspanattachment(this)" onmouseout="hidespanattachment(this)"><a style="display:inline;" href="'+item[1]+'">'+item[2]+'</a>'+
							'<span class="easyui-linkbutton"  style="position:relative;top:-5px;font-size:16px;margin-left:10px;display:none;" onclick="deleteattachment(this,'+item[0]+')">x</span></div>';
						})
						$("#attachment_modal").html(str);
					}else{
						$("#attachment_modal").html('');
					}
					//关联的活动
					if(result.listtravel!=null){
						var str="";
						$.each(result.listtravel,function(i,item){
							str+='<li onmouseover="showspantravel(this)" onmouseout="hidespantravel(this)"><a style="display:inline-block;" href="#" onclick="travelInfo('+item.id+')">'+item.title+
			       			 '</a><span   style="position:relative;top:-5px;font-size:16px;margin-left:10px;" onclick="deletetravel(this\,'+item.id+')">x</span></li>';
						})
						$("#right-travel_modal").html(str);
					}else{
						$("#right-travel_modal").html("");

					}
				 
				 $("#right-name_modal").val(result.taskself.name);//设置name
				 $("#right-content_modal").val(result.taskself.content);//设置内容
				 $("#div1_modal").css("display","none");
				 $("#responseibility_modal").text(result.taskself.responsibility);
				 $("#right-due_modal").text(result.taskself.due);
				 $("#div2_modal").css('display','none');
				 $("#div3_modal").css("display",'none');
				 $("#div4_modal").css('display','none');
				 /* //点击上级元素时，同步row
				 var rows=$("#dg").datagrid("getRows");
				 for(var i=0;i<rows.length;i++){
					 if(rows[i].id==result.taskself.id){
						 $("#dg").datagrid('selectRow',i);
						 break;
					 }
				 }
				 var row=$("#dg").datagrid("getSelected");
				 if(row.status==0){
	  				 $("#right-handle li:first").text("标记完成");
	  			 }else{
	  				 $("#right-handle li:first").text("标记未完成");
	  			 } */
			 }
		 }
	 })
}
function newTask(){
    $('#dlg').dialog('open').dialog('setTitle','New Task');
    KindEditor.create("#editor_id",{
		 cssPath:'editor/plugins/code/prettify.css',
 		 resize:0,
		 uploadJson:'editor/jsp/upload_json.jsp',
	     fileManagerJson : 'editor/jsp/file_manager_json.jsp',
		 allowPreviewEmoticons:true,
		 allowImageUpload:true,			
		 width:'100%',
		 items:['source','|','insertfile'],
		 afterBlur:function() {
		      this.sync();
		  }
		 }) ; 
   
    $('#fm').form('clear');
}
function doadd(){
	$.ajax({
		url:'<%=request.getContextPath()%>/task?method=add',
		type:'post',
		dataType:'json',
		data:{name:$("#name").val(),content:$("#editor_id").val(),due:$("#due").datebox('getValue'),responsibility:$("#responsibility").combogrid('getValue'),joins:$('input',$("#joins").next('span')).val()},
		beforeSend:function(){
			if($("#editor_id").val()==null||$("#editor_id").val()==""){
				$.messager.show({
					title:'提示',
					msg:"还没填写任务内容"
				})
				return false;
			}
			if(!$("#fm").form('validate')){
           	 return false;
            }

		},
		success:function(result){
			if(result.success){
				$.messager.show({
					title:'提示',
					msg:'创建成功'
				})
				$("#dlg").dialog('close');
				$('#dg').datagrid('reload');
			}
		}
	})
} 
function newSubTask(){
    $('#dlg2').dialog('open').dialog('setTitle','New Task');
    KindEditor.create("#editor_id2",{
		 cssPath:'editor/plugins/code/prettify.css',
 		 resize:0,
		 uploadJson:'editor/jsp/upload_json.jsp',
	     fileManagerJson : 'editor/jsp/file_manager_json.jsp',
		 allowPreviewEmoticons:true,
		 allowImageUpload:true,			
		 width:'100%',
		 items:['source','|','insertfile'],
		 afterBlur:function() {
		      this.sync();
		  }
		 }) ; 
   
    $('#fm').form('clear');
}
function doSubadd(){
	var row=$('#dg').datagrid("getSelected");
	$.ajax({
		url:'<%=request.getContextPath()%>/task?method=addsub',
		type:'post',
		dataType:'json',
		data:{parentid:row.id,name:$("#name2").val(),content:$("#editor_id2").val(),due:$("#due2").datebox('getValue'),responsibility:$("#responsibility2").combogrid('getValue'),joins:$('input',$("#joins2").next('span')).val()},
		beforeSend:function(){
			if($("#editor_id2").val()==null||$("#editor_id2").val()==""){
				$.messager.show({
					title:'提示',
					msg:"还没填写任务内容"
				})
				return false;
			}
			if(!$("#fm2").form('validate')){
           	 return false;
            }

		},
		success:function(result){
			if(result.success){
				$.messager.show({
					title:'提示',
					msg:'创建成功'
				})
                var str='<tr data-toggle="modal" href="#myModal"><td>'+$("#name2").val()+'</td><td>'+$("#due2").datebox('getValue')+'</td></tr>';
                $("#right-task-tab").prepend(str);
				$("#dlg2").dialog('close');
				$('#dg').datagrid('reload');
			}
		}
	})
}
function deleteTask(){
	var row = $('#dg').datagrid('getSelected');
	if(row){
		$.messager.confirm('Confirm','Are you sure you want to delete this task?',function(r){
            if (r){
                $.post('<%=request.getContextPath()%>/task?method=deletetask',{id : row.id},function(result) {
					if (result.success) {
						$.messager.show({
							title:'提示',
							msg:'删除成功'
						})
						cancelright();
						$("#dg").datagrid('reload');
					} else {
						$.messager.show({ // show error message
									title : 'Error',
									msg : '删除任务失败'
								});
					
					}
				}, 'json');
		     }
	});
	}
}
function complete(){
	var row = $('#dg').datagrid('getSelected');
	if(row.status==0){
		row.status=1;
		$("#right-handle li:first").text("标记未完成");
		
	}else{
		row.status=0;
		$("#right-handle li:first").text("标记完成");

	}
	$.ajax({
		url:"<%=request.getContextPath()%>/task?method=changestatus",
		type:'post',
		dataType:'json',
		data:{status:row.status,id:row.id},
		beforeSend:function(){
		},
		success:function(result){
			if(result.success){
				$("#dg").datagrid('reload');
				$.messager.show({
					title:'提示',
					msg:'修改成功'
					
				})
			}
		}
	})
}
</script>
<script>
function logout(){
		$.messager.confirm('Confirm','Are you sure you want to logout?',function(r){
            if (r){
                $.post('<%=request.getContextPath()%>/logout',function(result) {
					if (result.success) {
						$.messager.show({ // show error message
							title : '提示',
							msg : '退出成功'
						});
			           }
				 else {
						$.messager.show({ // show error message
									title : '提示',
									msg : '登录已过期，重新登录'
								});
					   }
				}, 'json');
    			window.open('<%=request.getContextPath()%>/index.jsp','_self');

		     }
	});
}
function profile(){
	window.open('<%=request.getContextPath()%>/profile?method=page','_self');
}
function gohome(){
	window.open('<%=request.getContextPath()%>/dashboard','_self');
}

function showCombox1(){
	 $("#responseibility").css('display','none');
	 $("#responseibility-btn").css('display','none');
	 $("#div1").css("display",'inline');
	 $("#mycom").combobox("showPanel");//panel直接是打开的
	 $('input',$("#mycom").next('span')).focus();//input直接是获取焦点的
};

function hideCombox1(){
	if($("#div1").css('display')!='none'){
		var row=$("#dg").datagrid('getSelected');
		 $("#responseibility").css('display','inline');
		 $("#responseibility-btn").css('display','inline');
		 $("#div1").css("display",'none');
		 $("#mycom").combobox("hidePanel");//panel直接是打开的
		 $.ajax({
			 url:'<%=request.getContextPath()%>/task?method=updateresponsibility',
			 type:'post',
			 dataType:'json',
			 data:{responsibility:$("#mycom").combobox('getValue'),id:row.id},
			 beforeSend:function(){
				 if($("#mycom").combobox('getValue')==''){
					 return false;
				 }
				 return true;
			 },
			 success:function(data){
				if(data.success){
					$.messager.show({
						title:'提示',
						msg:'修改成功'
					})
					
					$("#responseibility").text($("#mycom").combobox('getValue'));
					$("#dg").datagrid('reload');
				}
			}
		 })
	}
	
}
function showspan(){
	if($("#div1").css('display')!='inline'){
		$("#responseibility-btn").css('display','inline');
	}
}
function hidespan(){
	$("#responseibility-btn").css('display','none');
}	
function showspan2(){
	if($("#div2").css('display')=='none'){
		$("#responseibility-btn2").css('display','inline');
	}
}
function hidespan2(){
	$("#responseibility-btn2").css('display','none');
}	


function showdatebox(){
	 $("#right-due").css('display','none');
	 $("#responseibility-btn2").css('display','none');
	 $("#div2").css("display",'inline');
	 $('input',$("#datebox").next('span')).focus();//input直接是获取焦点的
	 $("#datebox").datebox("showPanel");//panel直接是打开的

};
 function hidedatebox(){
	if($("#div2").css('display')!='none'){
		 var row=$("#dg").datagrid('getSelected');
		 $("#right-due").css('display','inline');
		 $("#responseibility-btn2").css('display','inline');
		 $("#div2").css("display",'none');
		 $("#datebox").datebox("hidePanel");//panel直接是打开的
		 $.ajax({
			 url:'<%=request.getContextPath()%>/task?method=updatedatime',
			 dataType:'json',
			 type:'post',
			 data:{due:$("#datebox").datebox('getValue'),id:row.id},
			 beforeSend:function(){
				 if($("#datebox").datebox('getValue')==''){
					 return false;
				 }
				 return true;
				 
			 },
			 success:function(result){
				 if(result.success){
					 $.messager.show({
						 title:'提示',
						 msg:'修改成功'
					 })
					 $("#right-due").text($("#datebox").datebox('getValue'));
					 $("#dg").datagrid('reload');
				 }
			 }
			 
		 })
	}

};

function showspan3(){
	if($("#div3").css('display')=='none'){
		$("#responseibility-btn3").css('display','inline');
	}
}
function hidespan3(){
	$("#responseibility-btn3").css('display','none');

}
function showjoins(){
	 $("#responseibility-btn3").css('display','none');
	 $("#div3").css("display",'inline');
	 $('input',$("#mycom3").next('span')).focus();//input直接是获取焦点的
	 $("#mycom3").combobox("showPanel");//panel直接是打开的
}
function hdiejoins(){
	if($("#div3").css('display')!='none'){
		var row=$("#dg").datagrid('getSelected');
		 $("#responseibility-btn3").css('display','inline');
		 $("#div3").css("display",'none');
		 $("#mycom3").combobox("hidePanel");//panel直接是打开的
		 $.ajax({
			 url:'<%=request.getContextPath()%>/task?method=addjoin',
			 type:'post',
			 dataType:'json',
			 data:{join:$("#mycom3").combobox("getValue"),id:row.id},
			 beforeSend:function(){
				 if($("#mycom3").combobox("getValue")==''){
					 return false;
				 }
				 return true;
			 },
			 success:function(result){
				 if(result.success){
					 if($("#join-right").text().indexOf(($("#mycom3").combobox("getValue")))>-1){
						 
					 }else{
						 $.messager.show({
							 title:'提示',
							 msg:'修改成功'
						 })
						 var str='<span style="padding:20px;font-size:16px;" onmouseover="showspanjoin(this)" onmouseout="hidespanjoin(this)">'+$("#mycom3").combobox("getValue")+
						   '<span class="easyui-linkbutton"  style="position:relative;top:-5px;font-size:20px;margin-left:10px;display:none" onclick="deletejoin(this)">x</span></span>';
						   
						 $("#join-right").append(str);
					 }

				 }
				 
			 }
		 })
	}
}

function showspan4(){
	if($("#div4").css('display')=='none'){
		$("#responseibility-btn6").css('display','inline');
	}

}
function hidespan4(){
	$("#responseibility-btn6").css('display','none');

}
function showusers(){
	 $("#div4").css('display','inline');
	 $("#responseibility-btn6").css('display','none');
	 $('input',$("#mycom4").next('span')).focus();//input直接是获取焦点的
	 $("#mycom4").combobox("showPanel");//panel直接是打开的
}
function hideusers(){
	if($("#div4").css('display')!='none'){
		 var row=$("#dg").datagrid('getSelected');
		 $("#responseibility-btn6").css('display','inline');
		 $("#div4").css("display",'none');
		 $("#mycom4").combobox("hidePanel");//panel直接是打开的
		 $.ajax({
			 url:'<%=request.getContextPath()%>/task?method=addusers',
             type:'post',
             dataType:'json',
             data:{id:row.id,uid:$("#mycom4").combobox('getValue')},
             beforeSend:function(){
            	 if($("#mycom4").combobox('getValue')==""||$("#mycom4").combobox('getValue')==null){
            		 return false;
            	 }
            	 return true;
             },
             success:function(result){
            	 if(result.success){
            		    	 $.messager.show({
                    			 title:'提示',
                    			 msg:'关联成功'
                    		 })
                			 var str='<li onmouseover="showspanuser(this)" onmouseout="hidespanuser(this)"><a style="display:inline-block;" href="#" onclick="userInfo(\''+$("#mycom4").combogrid('getValue')+'\')">'+$("#mycom4").combobox('getValue')+
                			 '</a><span   style="position:relative;top:-5px;font-size:16px;margin-left:10px;" onclick="deleteuser(this\,\''+$("#mycom4").combogrid('getValue')+'\')">x</span></li>';
                    		 $("#right-users").prepend(str);
            			
            	 }
             }
		 })
	}
}
/* function showspan5(){
	$("#insertfile").css('display','inline');
}
function hidespan5(){
$("#insertfile").css('display','none');

}
 */

function showspanjoin(ele){
	$(ele).children().css({'display':'inline','color':'blue'});
}
function hidespanjoin(ele){
	$(ele).children().css("display",'none');
}
function deletejoin(ele){
	$.messager.confirm('Confirm','确定要删除?',function(r){
		if(r){
			  $.post('<%=request.getContextPath()%>/task?method=deletejoin',{join:$(ele).parent().text().substring(0,$(ele).parent().text().length-1)},function(result) {
					if (result.success) {
						$.messager.show({
							title:'提示 ',
							msg:'删除成功'
							
						})
						$(ele).parent().remove();
					} else {
						$.messager.show({ // show error message
									title : 'Error',
									msg : '删除任务失败'
								});
					}
				}, 'json');
		}
	})
}

function  showlinkx(ele){
	$(ele).children().css('display','inline');
}
function hidelinkx(ele){
	$(ele).children().css('display','none');
}
function deletelink(ele,id){
	$.messager.confirm('Confirm','确定要删除？',function(r){
		if(r){
			  $.post('<%=request.getContextPath()%>/task?method=deletelink',{taskid:id},function(result) {
					if (result.success) {
						$.messager.show({
							title:'提示 ',
							msg:'删除成功'
							
						})
						$(ele).parent().remove();
					} else {
						$.messager.show({ // show error message
									title : 'Error',
									msg : '删除任务失败'
								});
					}
				}, 'json');
		}
	})
}
function deleteattachment(ele,id){
	$.messager.confirm('Confirm','确定要删除？',function(r){
		if(r){
			  $.post('<%=request.getContextPath()%>/task?method=deleteattachment',{id:id},function(result) {
					if (result.success) {
						$.messager.show({
							title:'提示 ',
							msg:'删除成功'
							
						})
						$(ele).parent().remove();
					} else {
						$.messager.show({ // show error message
									title : 'Error',
									msg : '删除任务失败'
								});
					}
				}, 'json');
		}
	})
}
 function showspanattachment(ele){
	$(ele).children("span").css('display','inline');
}
function hidespanattachment(ele){
	$(ele).children("span").css('display','none');
}  
function showspanuser(ele){
	$(ele).children('span').css('display','inline');
}
function hidespanuser(ele){
	$(ele).children('span').css('display','none');
}
function deleteuser(ele,uid){
	var row=$('#dg').datagrid('getSelected');
	$.messager.confirm('Confirm','确定要删除？',function(r){
		if(r){
			  $.post('<%=request.getContextPath()%>/task?method=deleteuser',{taskid:row.id,uid:uid},function(result) {
					if (result.success) {
						$.messager.show({
							title:'提示 ',
							msg:'删除成功'
							
						})
						$(ele).parent().remove();
					} else {
						$.messager.show({ // show error message
									title : 'Error',
									msg : '删除任务失败'
								});
					}
				}, 'json');
		}
	})
}


function userInfo(uid){
	 $('#dlg3').dialog('open').dialog('setTitle','会员详情');
	 $.ajax({
		 url:'<%=request.getContextPath()%>/task?method=readuser',
		 type:'post',
		 dataType:'json',
		 data:{uid:uid},
		 beforeSend:function(){
			 
		 },
		 success:function(result){
			 if(result.success){
				 $('#uid').text(result.user.uid);
				 $("#username").text(result.user.name);
				 $("#type").text(function(){
					 switch(result.user.type){
					 case 1:
						 return '普通会员';
						 break;
					 case 2:
						 return 'vip会员';
						 break;
					 default:
							 break;
					 }
				 });
				 $("#phone").text(result.user.phone);
				 $("#email").text(result.user.email);
				 $("#school").text(result.user.school);
				 $("#grade").text(function(){
					 switch(result.user.grade){
					    case 1:
							return '大一';
							break;
						case 2:
							return '大二';
							break;
						case 3:
							return '大三';
							break;
						case 4:
							return '大四';
							break;
						default:
							break;
					 }
				 });
				 $('#userdue').text(result.user.due);
				 $("#assistid").text(result.user.assistid);
				 
			 }
		 }
		
		})
	}
	
function showspan7(){
	if($("#div7").css('display')=='none'){
		$("#responsibility-btn7").css('display','inline');
	}
}
function  hidespan7(){
	$("#responsibility-btn7").css('display','none');
}
	
function showCombox7(){
	$("#div7").css("display","inline");
	$("#responsibility-btn7").css('display','none');
	$("#mycom7").combobox('showPanel');
	$('input',$("#mycom7").next('span')).focus(); 
}
function hideCombox7(){
	var row=$("#dg").datagrid('getSelected');
	 if($("#div7").css('display')!='none'){
		$('#responsibility-btn7').css('display','inline');
		$("#div7").css('display',"none");
		$('#mycom7').combobox('hidePanel');
		$.ajax({
			url:'<%=request.getContextPath()%>/task?method=addtravel',
			type:'post',
			dataType:"json",
			data:{taskid:row.id,travelid:$('#mycom7').combobox('getValue')},
			beforeSend:function(){
				if($('#mycom7').combobox('getValue')==""||$("#mycom7").combobox('getValue')==null){
					return false;
				}
				return true;
			},
			success:function(result){
				if(result.success){
					$.messager.show({
						title:'提示',
						msg:'关联成功'
						
					})
					var str='<li onmouseover="showspantravel(this)" onmouseout="hidespantravel(this)"><a style="display:inline-block;" href="#" onclick="travelInfo('+$("#mycom7").combobox('getValue')+')">'+$('#mycom7').combobox('getText')+
       			 '</a><span   style="position:relative;top:-5px;font-size:16px;margin-left:10px;" onclick="deletetravel(this\,\''+$("#mycom7").combobox('getValue')+'\')">x</span></li>';
           		 $("#right-travel").prepend(str);
				}
			}
		})
	} 
}
function travelInfo(id){
	$("#dlg4").dialog('open').dialog('setTitle','活动详情');
	$.ajax({
		url:'<%=request.getContextPath()%>/task?method=travelinfo',
		dataType:'json',
		type:'post',
		data:{travelid:id},
		beforeSend:function(){
			
		},
		success:function(result){
			if(result.success){
				$("#tit").text(result.travel.title);
				$("#span1").text(result.travel.datetime);
				$("#span2").text(result.travel.money);
				$("#travel").append(result.travel.content);
			}
		}
	})
}
function showspantravel(ele){
	$(ele).children('span').css('display','inline');
}
function hidespantravel(ele){
	$(ele).children('span').css('display','none')
	
}

function deletetravel(ele,id){
	var row=$("#dg").datagrid('getSelected');
	$.messager.confirm('Confirm','确定要删除？',function(r){
		if(r){
			  $.post('<%=request.getContextPath()%>/task?method=deletetravel',{taskid:row.id,travelid:id},function(result) {
					if (result.success) {
						$.messager.show({
							title:'提示 ',
							msg:'删除成功'
							
						})
						$(ele).parent().remove();
					} else {
						$.messager.show({ // show error message
									title : 'Error',
									msg : '删除失败'
								});
					}
				}, 'json');
		}
	})
	
}



</script>
<script>
 /*-------菜单按钮---------------*/
 function myTask(){
	 var url="<%=request.getContextPath()%>/task?method=unfinishlist";
	 $("#dg").datagrid('reload',url);
 }
 function myCreate(){
	 var url="<%=request.getContextPath()%>/task?method=mycreate";
	 $("#dg").datagrid('reload',url);
	 
 }
 function hasFinishedTask(){
	 var url="<%=request.getContextPath()%>/task?method=finishlist";
	 $("#dg").datagrid('reload',url);
 }
 function allTask(){
	 var url="<%=request.getContextPath()%>/task?method=list";
	 $("#dg").datagrid('reload',url);
 }

</script>
</head>
<body  class="cbp-spmenu-push">
 <div >
        <nav class="cbp-spmenu cbp-spmenu-vertical cbp-spmenu-right" id="cbp-spmenu-s2" style="background:rgb(238, 238, 238);overflow-y:scroll;overflow-x:hidden;border:1px solid gray;">
		<h3>任务</h3>
		<ul id="right-handle" style="list-style:none;">
		<li onclick="complete()">标记完成</li>
		<li onclick="deleteTask()">删除</li>
		<li onclick="cancelright()">关闭</li>
		</ul>
		<div style="width:95%;min-height:60px;margin:20px auto;">
		 <textarea id="right-name" title="可点击修改"  style="overflow:hidden;height:auto;width:100%;background:white" ></textarea>
		</div>
		<div style="background:white;width:95%;height:auto;margin:20px auto 0px;">
		 <div style="padding-top:10px;" onmouseover="showspan()" onmouseout="hidespan()" id="div-responsibility">负责人:
		 <span id="responseibility"></span> 
	     <span id="responseibility-btn" title="修改负责人" style="padding:5px;border-radius:10px 10px;color:blue;border:1px solid blue;display:none" >edit</span>
		  <div id="div1">
		  <select id="mycom" class="easyui-combogrid " name="assistid" style="width:250px" data-options="
		                        panelWidth: 200,
								idField: 'id',
								textField: 'name',
								url: '<%=request.getContextPath() %>/assist?method=list',
								method: 'post',
								pagination : true,
								columns: [[
									{field:'id',title:'编号',width:80}
								]],
								fitColumns: true,
								onSelect:function(){
								 		hideCombox1();
								}
							">
		 </select>
		 </div>
		 </div><hr/>
		 <div onmouseover="showspan2()" onmouseout="hidespan2()" id="div-datebox">到期时间:
		 <span id="right-due"></span>
	     <span id="responseibility-btn2" title="编辑到期时间" style="padding:5px;border-radius:10px 10px;color:blue;border:1px solid blue;display:none;" >edit</span>
		 <div id="div2"><input id="datebox"  data-options="onSelect:hidedatebox" class="easyui-datebox"></div>
		 </div>
		 <div style="clear:both;"></div><hr/>
		 <div onmouseover="showspan3()" onmouseout="hidespan3()" id="div-joins"  >参与人:
		 <div id="join-right" style="display:inline-block;overflow:auto;"></div>
	     <span id="responseibility-btn3" title="添加负责人" style="padding:5px;border-radius:10px 10px;color:blue;border:1px solid blue;display:none" >add</span>
		  <div id="div3">
		   <select  id="mycom3" class="easyui-combogrid right-combox"  name="assistid" style="width:200px;height:0px;" data-options="
								panelWidth: 200,
								idField: 'id',
								textField: 'name',
								url: '<%=request.getContextPath() %>/assist?method=list',
								method: 'get',
								pagination : true,
								columns: [[
									{field:'id',title:'编号',width:80}
								]],
								fitColumns: true,
								onSelect:function(){
								 hdiejoins();
								}
							">
		</select>
		  </div>
		 </div><hr/>
		<div style="padding-bottom:20px;height:auto">		 
		<textarea id="right-content" title="可编辑任务详情"  style="overflow:hidden;height:auto;width:100%;background:white;border:none" placeholder="这里可以添加任务详情....."></textarea>
        </div>
		</div>
		<div style="background:white;width:95%;min-height:100px;margin:20px auto;">
		
		<div id="" >附件:	<span class="easyui-linkbutton" id="insertfile" iconCls="icon-add"></span>
		<div id="attachment">
		</div>
		
		</div><hr/>
		<div >上级任务:
		 <span id="parent-content"></span>
		</div><hr/>
		<div id="right-task" style="padding-bottom:20px;">子任务：
		<span class="easyui-linkbutton" iconCls="icon-add"
					plain="true" onclick="newSubTask()">新建子任务</span>
		   <table id='right-task-tab' style="border:1px dotted gray" class="table"></table>
		</div>
		</div>
		<div style="background:white;width:95%;min-height:100px;margin:20px auto;"   onmouseover="showspan4()" onmouseout="hidespan4()">关联会员:
		<span id="responseibility-btn6" title="关联会员" style="padding:5px;border-radius:10px 10px;color:blue;border:1px solid blue;display:none" >add</span>
		<div id="div4">
		  <select  id="mycom4" class="easyui-combogrid right-combox"  style="width:200px;height:0px;" data-options="
								panelWidth: 200,
								idField: 'uid',
								textField: 'name',
								url: '<%=request.getContextPath() %>/member?method=total',
								method: 'get',
								pagination : true,
								columns: [[
									{field:'uid',title:'会员id',width:80},
									{field:'name',title:'会员姓名',width:80}
								]],
								fitColumns: true,
								onSelect:function(){
								 hideusers();
								}
							">
		</select>
		</div>
		<div><ul id="right-users"></ul></div>
		</div>
		<div style="background:white;width:95%;min-height:100px;margin:20px auto;"   onmouseover="showspan7()" onmouseout="hidespan7()">关联活动:
		<span id="responsibility-btn7" title="关联活动" style="padding:5px;border-radius:10px 10px;color:blue;border:1px solid blue;display:none"  >add</span>
		<div id="div7">
		  <select  id="mycom7" class="easyui-combogrid right-combox"  style="width:200px;height:0px;" data-options="
								panelWidth: 200,
								idField: 'id',
								textField: 'title',
								url: '<%=request.getContextPath() %>/travel?method=list',
								method: 'get',
								pagination : true,
								columns: [[
									{field:'id',title:'会员id',width:80},
									{field:'title',title:'会员姓名',width:80}
								]],
								fitColumns: true,
								onSelect:function(){
								 hideCombox7();
								}
							">
		</select>
		</div>
		<div><ul id="right-travel"></ul></div>
		</div>
		</nav>
        </div>
<!--Header-part-->
<div id="header" onclick="cancelright()">
	<h1>
		<a href="dashboard.html">Matrix Admin</a>
	</h1>
</div>
<!--close-Header-part-->
	<!-- header menu -->
<ul style="position:absolute;left:200px;top:20px;list-style:none;">
 <li id="li2" style="float:left;padding:5px;color:#0094ff;font-size:12px;" onclick="gohome()">首页</li>
</ul>
<!-- header menu -->
<div>


<h3 style="position:absolute;top:6px;right:30px;font-size:16px;height:35px;line-height:32px;background:white;border-radius:10px 10px">
<a href="#" onclick="myTask()"><span style="padding:5px;border-radius:10px 10px ;color:white;background:red;" id="count"></span></a>
<a href="#" class="easyui-menubutton" data-options="menu:'#mm5',iconCls:'icon-man'" style="color:#0094ff;">${sessionScope.assist.id }</a>
</h3>
</div>
<div id="mm5" style="width:150px;">
		<div data-options="iconCls:'icon-undo'" onclick="profile()">个人设置</div>
		<div class="menu-sep"></div>
		<div>我的任务</div>
		<div class="menu-sep"></div>
		<div>系统消息</div>
		<div class="menu-sep"></div>
		<div onclick="logout()">安全退出</div>
</div>
<!-- side bar start -->
<div id="sidebar" onclick="cancelright()">
  <ul>
    <li><a href="<%=request.getContextPath()%>/dashboard"><i class="icon icon-home"></i> <span>Dashboard控制面板</span></a> </li>
    <li> <a href="<%=request.getContextPath()%>/study?method=page"><i class="icon icon-signal"></i> <span>Study news留学信息</span></a> </li>
    <li> <a href="<%=request.getContextPath()%>/travel?method=page"><i class="icon icon-inbox"></i> <span>Travel New活动信息</span></a> </li>
    <li><a href="<%=request.getContextPath()%>/news?method=page"><i class="icon icon-th"></i> <span>Recent News近期新闻</span></a></li>
    <li><a href="<%=request.getContextPath()%>/member?method=page"><i class="icon icon-fullscreen"></i> <span>Members centre会员中心</span></a></li>
    <c:choose>
     <c:when test="${sessionScope.assist.type eq 0 }">
          <li><a href="<%=request.getContextPath() %>/assist"><i class="icon icon-th-list"></i> <span>助理管理</span></a></li>
     </c:when>
    </c:choose>
    <li class="active" >
    <a href="<%=request.getContextPath() %>/task"><i class="icon icon-th-list"></i> <span>任务管理</span></a>
   </li>
  </ul>
</div>
	<div id="content" class="easyui-layout" onclick="cancelright()">
       
		<div region="center" 
			style="padding: 0px; background: #eee;"  >
		 <table id="dg"  toolbar="#toolbar" ></table>
		 <div id="toolbar">
		           <a href="#" class="easyui-linkbutton" iconCls="icon-add"
					plain="true" onclick="newTask()">新建任务</a><a href="#" class="easyui-linkbutton"
					 iconCls="icon-large-smartart" plain="true" onclick="myTask()">我的任务</a> <a href="#"
					class="easyui-linkbutton" iconCls="icon-large-smartart" plain="true"
					onclick="myCreate()">我创建的任务</a> <a href="#"
					class="easyui-linkbutton" iconCls="icon-large-smartart" plain="true"
					onclick="hasFinishedTask()">已完成的任务</a><a href="#"
					class="easyui-linkbutton" iconCls="icon-large-smartart"
					plain="true" onclick="allTask()">全部任务 </a>
		</div>
		<!-- dialog弹出框 -->
			<div id="dlg" class="easyui-dialog"
				style="width:600px; height: 600px; padding: 10px 20px"
				closed="true" buttons="#dlg-buttons">
				<div class="ftitle" style="text-align: center;">添加任务</div>
			
				<form id="fm" method="post" novalidate>
					<div class="fitem">
						<label>任务名称:</label> <input name="name"  id="name" class="easyui-textbox"
							required="true"  style="width:250px"  >
					</div>
					<div class="fitem">
						<label>任务内容:</label>
					   <textarea style="float:left;"  class="easyui-validatebox" data-options="required:true" id="editor_id" ></textarea>
					</div>
					<div class="fitem">
						<label>截止日期:</label> <input  style="width:250px" name="due" id="due" class="easyui-datebox"
							required="true">
					</div>
					<div class="fitem">
						<label>指派负责人:</label> 
						<select class="easyui-combogrid"  required='true' name="responsibility" id="responsibility" style="width:250px" data-options="
								panelWidth: 500,
								idField: 'id',
								textField: 'name',
								url: '<%=request.getContextPath() %>/assist?method=list',
								method: 'get',
								pagination : true,
								columns: [[
									{field:'id',title:'编号',width:80},
									{field:'name',title:'姓名',width:120},
									{field:'department',title:'部门',width:80,align:'right'},
									{field:'phone',title:'电话',width:80,align:'right'}
								]],
								fitColumns: true
							">
						</select>
					</div>
					<div class="fitem">
						<label>参与人:</label> 
						<select class="easyui-combogrid easyui-textbox"  name="joins" style="width:250px" id="joins" data-options="
								panelWidth: 500,
								idField: 'id',
								textField: 'name',
								url: '<%=request.getContextPath() %>/assist?method=list',
								method: 'get',
								pagination : true,
								multiple:true, 
								columns: [[
									{field:'id',title:'编号',width:80},
									{field:'name',title:'姓名',width:120},
									{field:'department',title:'部门',width:80,align:'right'},
									{field:'phone',title:'电话',width:80,align:'right'}
								]],
								fitColumns: true
							">
						</select>
					</div>
				</form>
			</div>
			<div id="dlg-buttons">
				<a href="javascript:void(0)" class="easyui-linkbutton c6"
					iconCls="icon-ok" onclick="doadd()" style="width:90px">Save</a> <a
					href="javascript:void(0)" class="easyui-linkbutton"
					iconCls="icon-cancel"
					onclick="javascript:$('#dlg').dialog('close')" style="width:90px">Cancel</a>
			</div>
		   <div id="dlg2" class="easyui-dialog"
				style="width:600px; height: 600px; padding: 10px 20px;z-index:100000"
				closed="true" buttons="#dlg-buttons2">
				<div class="ftitle" style="text-align: center;">添加子任务</div>
			
				<form id="fm2" method="post" novalidate>
					<div class="fitem">
						<label>任务名称:</label> <input name="name"  id="name2" class="easyui-textbox"
							required="true"  style="width:250px"  >
					</div>
					<div class="fitem">
						<label>任务内容:</label>
					   <textarea style="float:left;"  class="easyui-validatebox" data-options="required:true" id="editor_id2" ></textarea>
					</div>
					<div class="fitem">
						<label>截止日期:</label> <input  style="width:250px" name="due" id="due2" class="easyui-datebox"
							required="true">
					</div>
					<div class="fitem">
						<label>指派负责人:</label> 
						<select class="easyui-combogrid"  required='true' name="responsibility" id="responsibility2" style="width:250px" data-options="
								panelWidth: 500,
								idField: 'id',
								textField: 'name',
								url: '<%=request.getContextPath() %>/assist?method=list',
								method: 'get',
								pagination : true,
								columns: [[
									{field:'id',title:'编号',width:80},
									{field:'name',title:'姓名',width:120},
									{field:'department',title:'部门',width:80,align:'right'},
									{field:'phone',title:'电话',width:80,align:'right'}
								]],
								fitColumns: true
							">
						</select>
					</div>
					<div class="fitem">
						<label>参与人:</label> 
						<select class="easyui-combogrid easyui-textbox"  name="joins" style="width:250px" id="joins2" data-options="
								panelWidth: 500,
								idField: 'id',
								textField: 'name',
								url: '<%=request.getContextPath() %>/assist?method=list',
								method: 'get',
								pagination : true,
								multiple:true, 
								columns: [[
									{field:'id',title:'编号',width:80},
									{field:'name',title:'姓名',width:120},
									{field:'department',title:'部门',width:80,align:'right'},
									{field:'phone',title:'电话',width:80,align:'right'}
								]],
								fitColumns: true
							">
						</select>
					</div>
				</form>
			</div>
			<div id="dlg-buttons2">
				<a href="javascript:void(0)" class="easyui-linkbutton c6"
					iconCls="icon-ok" onclick="doSubadd()" style="width:90px">Save</a> <a
					href="javascript:void(0)" class="easyui-linkbutton"
					iconCls="icon-cancel"
					onclick="javascript:$('#dlg2').dialog('close')" style="width:90px">Cancel</a>
			</div>
			
			<div id="dlg3" class="easyui-dialog"
				style="width:600px; height: 500px; padding: 10px 20px"
				closed="true" buttons="#dlg-buttons3">
				<div class="ftitle" style="text-align: center;">会员资料</div>
				<table class="table table-bordered table-invoice">
                  <tbody>
                    <tr>
                    <tr>
                      <td><strong> 用户id:</strong></td>
                      <td id='uid'></td>
                    </tr>
                    <tr>
                      <td><strong>姓名</strong></td>
                      <td id="username"></td>
                    </tr>
                    <tr>
                      <td><strong>会员类型</strong></td>
                      <td id="type"></td>
                    </tr>
                    <tr>
                    <td ><strong>联系电话</strong></td>
                    <td id='phone'></td>
                    </tr>
                    <tr>
                     <td><strong>电子邮箱</strong></td>
                     <td id='email'></td>
                    </tr>
                    <tr>
                     <td><strong>在读学校</strong></td>
                     <td id="school"></td>
                    </tr>
                    <tr>
                     <td><strong>在读年级</strong></td>
                     <td id='grade'></td>
                    </tr>
                    <tr>
                     <td><strong>会员有效期至</strong></td>
                     <td id='userdue'></td>
                    </tr>
                    <tr>
                     <td><strong>个人助理</strong></td>
                     <td id='assistid'></td>
                    </tr>
                    </tbody>
                </table>
			</div>
			<div id="dlg-buttons3">
			<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg3').dialog('close')" style="width:90px">Cancel</a>
			</div>
			
			<div id="dlg4" class="easyui-dialog"
				style="width:900px; height: 600px; padding: 10px 20px"
				closed="true" buttons="#dlg-buttons4">
				<div id="travel">
				 <h3 id="tit" style="text-align:center;"></h3>
				 <div>发布时间:<span id="span1" style="padding:0px 500px 0px 10px;"></span>收费方式：<span id='span2'></span>元</div>
				<hr/>
				</div>
				
			</div>
			<div id="dlg-buttons4">
				 <a href="javascript:void(0)" class="easyui-linkbutton"
					iconCls="icon-cancel"
					onclick="javascript:$('#dlg4').dialog('close')" style="width: 90px">Cancel</a>
			</div>
			
		</div>
	</div>
	<div class="row-fluid">
		<div id="footer" class="span12">
			2016 &copy; <a href="http://themedesigner.in/">guangzhoushuntian
				information technology</a>
		</div>
	</div>

	
    <!-- Modal -->
 <div id="myModal" class="modal hide fade"  role="dialog" style="width:70%;left:35%;" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-header">
   
   <h5 id="modal-h5" class="modal-title" id="myModalLabel">任务</h5>
   <ul id="right-handle" style="list-style:none;">
		<li onclick="complete()">标记完成</li>
		<li onclick="deleteTask()">删除</li>
		<li class="close" data-dismiss="modal" aria-hidden="true">关闭</li>
	</ul>
  </div>
  <div class="modal-body" style="padding:0px;" >
    <div  >
        <nav class="cbp-spmenu1 cbp-spmenu-vertical2" id="cbp-spmenu-s1" style="overflow:hidden;border:1px solid gray;">
		
		<div style="width:95%;min-height:60px;margin:20px auto;">
		 <textarea id="right-name_modal" title="可点击修改"  style="overflow:hidden;height:auto;width:100%;background:white" ></textarea>
		</div>
		<div style="background:white;width:95%;height:auto;margin:20px auto 0px;">
		 <div style="padding-top:10px;" onmouseover="showspan()" onmouseout="hidespan()" id="div-responsibility">负责人:
		 <span id="responseibility_modal"></span> 
	     <span id="responseibility-btn" title="修改负责人" style="padding:5px;border-radius:10px 10px;color:blue;border:1px solid blue;display:none" >edit</span>
		  <div id="div1_modal">
		  <select id="mycom" class="easyui-combogrid " name="assistid" style="width:250px" data-options="
		                        panelWidth: 200,
								idField: 'id',
								textField: 'name',
								url: '<%=request.getContextPath() %>/assist?method=list',
								method: 'post',
								pagination : true,
								columns: [[
									{field:'id',title:'编号',width:80}
								]],
								fitColumns: true,
								onSelect:function(){
								 		hideCombox1();
								}
							">
		 </select>
		 </div>
		 </div><hr/>
		 <div onmouseover="showspan2()" onmouseout="hidespan2()" id="div-datebox">到期时间:
		 <span id="right-due_modal"></span>
	     <span id="responseibility-btn2" title="编辑到期时间" style="padding:5px;border-radius:10px 10px;color:blue;border:1px solid blue;display:none;" >edit</span>
		 <div id="div2"><input id="datebox"  data-options="onSelect:hidedatebox" class="easyui-datebox"></div>
		 </div>
		 <div style="clear:both;"></div><hr/>
		 <div onmouseover="showspan3()" onmouseout="hidespan3()" id="div-joins"  >参与人:
		 <div id="join-right_modal" style="display:inline-block;"></div>
	     <span id="responseibility-btn3" title="添加负责人" style="padding:5px;border-radius:10px 10px;color:blue;border:1px solid blue;display:none" >add</span>
		  <div id="div3">
		   <select  id="mycom3" class="easyui-combogrid right-combox"  name="assistid" style="width:200px;height:0px;" data-options="
								panelWidth: 200,
								idField: 'id',
								textField: 'name',
								url: '<%=request.getContextPath() %>/assist?method=list',
								method: 'get',
								pagination : true,
								columns: [[
									{field:'id',title:'编号',width:80}
								]],
								fitColumns: true,
								onSelect:function(){
								 hdiejoins();
								}
							">
		</select>
		  </div>
		 </div><hr/>
		<div style="padding-bottom:20px;height:auto">		 
		<textarea id="right-content_modal" title="可编辑任务详情"  style="overflow:hidden;height:auto;width:100%;background:white;border:none" placeholder="这里可以添加任务详情....."></textarea>
        </div>
		</div>
		<div style="background:white;width:95%;min-height:100px;margin:20px auto;">
		<div id="" >附件:	<span class="easyui-linkbutton" id="insertfile" iconCls="icon-add"></span>
		<div id="attachment_modal">
		</div>
		</div><hr/>
		<div >上级任务:
		 <span id="parent-content_modal"></span>
		</div><hr/>
		<div id="right-task_modal" style="padding-bottom:20px;">子任务：
		<span class="easyui-linkbutton" iconCls="icon-add"
					plain="true" onclick="newSubTask()">新建子任务</span>
		   <table id='right-task-tab_modal' style="border:1px dotted gray" class="table"></table>
		</div>
		</div>
		<div style="background:white;width:95%;min-height:100px;margin:20px auto;"   onmouseover="showspan4()" onmouseout="hidespan4()">关联会员:
        <div id="right-users_modal"></div>
        <span id="" title="关联任务" style="padding:5px;border-radius:10px 10px;color:blue;border:1px solid blue;display:none" >add</span>
		<div id="div4">
		  <select  id="mycom4" class="easyui-combogrid right-combox"  style="width:200px;height:0px;" data-options="
								panelWidth: 200,
								idField: 'uid',
								textField: 'name',
								url: '<%=request.getContextPath() %>/member?method=total',
								method: 'get',
								pagination : true,
								columns: [[
									{field:'uid',title:'会员id',width:80},
									{field:'name',title:'会员姓名',width:80}
								]],
								fitColumns: true,
								onSelect:function(){
								 hidelinked();
								}
							">
		</select>
		 </div>
		</div>
		<div style="background:white;width:95%;min-height:100px;margin:20px auto;"  >关联活动:
        <div id="right-travel_modal"></div>
        <span  title="关联任务" style="padding:5px;border-radius:10px 10px;color:blue;border:1px solid blue;display:none" >add</span>
		<div >
		  <select class="easyui-combogrid right-combox"  style="width:200px;height:0px;" data-options="
								panelWidth: 200,
								idField: 'id',
								textField: 'name',
								url: '<%=request.getContextPath() %>/travel?method=list',
								method: 'get',
								pagination : true,
								columns: [[
									{field:'id',title:'编号',width:80},
									{field:'title',title:'活动名称',width:80}
								]],
								fitColumns: true,
								onSelect:function(){
								 hidelinked();
								}
							">
		</select>
		 </div>
		</div>
		</nav>
        </div>
  </div>

</div> 

</body>
</html>
